package com.liuxvru.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.liuxvru.common.utils.SecurityUtils;
import com.liuxvru.project.domain.Customer;
import com.liuxvru.project.mapper.CustomerMapper;
import com.liuxvru.project.service.ICustomerService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 客户Service业务层处理
 *
 * @author liuxvru
 * @date 2024-11-22
 */
@Service
public class CustomerServiceImpl extends ServiceImpl<CustomerMapper, Customer>
        implements ICustomerService {
    /**
     * 查询客户列表
     *
     * @param customer 客户
     * @return 客户
     */
    @Override
    public List<Customer> selectCustomerList(Customer customer) {
        return baseMapper.selectCustomerList(customer);
    }

    @Override
    @Transactional
    public int edit(Customer customer) {
        customer.setUpdatedBy(SecurityUtils.getUserId());
        return 1;
    }

    @Override
    @Transactional
    public int add(Customer customer) {
        customer.setCreatedBy(SecurityUtils.getUserId());
        customer.setUpdatedBy(SecurityUtils.getUserId());
        this.baseMapper.insert(customer);
        return 1;
    }

}
